<!--<% if User.find_by_id(session[:user_id]).last_login == nil && User.find_by_id(session[:user_id]).role == 'student'%>
    Welcome First Time!
    <%= User.find_by_id(session[:user_id]).last_login %>
<% end %>-->

<h1><% if User.find_by_id(session[:user_id]).role == "camt" %>
      CAMT
  <% else %>
      <%= User.find_by_id(session[:user_id]).role.humanize %>
  <% end %></h1>

<h2 id="notice"><%= notice %></h2>

<div class="fbblueboxlite">

  <div id="JewelBoxMail" class="jewelMail" style="display:none;">
    <div class="uiHeader uiHeaderBottomBorder jewelHeader">
      <div class="clearfix uiHeaderTop">
        <%= link_to 'New Message', new_message_path %>
      </div>
    </div>
    <ul>
      <% for message in Message.all do %>
          <li class="jewelCase">
            <a class="" <%= link_to ' ...', message %> title>
              <div class="UIImageBlock" title>
                <div class="UIImageBlock_Content">
                  <div class="author"><strong><%= message.sender %></strong></div>
                  <div class="snippet"> <%= message.subject %> </div>
                <div style="font-size:10px"><%= message.body %></div>

              </div></div>
            </a>
          </li>

      <% end %>
      </ul>
      <br />


      </div>

      <a href="#JewelBoxMail" rel="facebox" style="font-weight:bold;">Messages</a>
      <a href="../messages" style="font-weight:bold;">Messages</a>
<%# ----------------------------------------------CAMT------------------------------------------- %>
<% if User.find_by_id(session[:user_id]).role == "camt"%>





    <table>
      <div class="fbgreybox" id="infoxxx">
        <h2>Students<!-- <%= link_to 'New Student', new_student_path, :align => :right%>--></h2>
      </div>
      <tr>
        <td>
          <table rules="rows" frame="void">
            <tr>
              <th width="50px">Title </th>
              <th width="150px">First name</th>
              <th width="200px">Last name</th>
              <th width="100px">Student ID</th>
              <th width="100px">Status</th>
              <th></th>
              <th></th>
            </tr>
            <% for student in Student.all do %>
                <tr>
                  <td><%= student.title %></td>
                  <td><%= student.firstname %></td>
                  <td><%= student.lastname %></td>
                  <td><%= student.student_id %></td>
                  <td>
                    <% if student.status == "Available" %>
                        <p style="margin:0px;color:#20b2aa;font-weight:bold;"><%= student.status %></p>
                    <% else %>
                        <p style="margin:0px;color:#dc143c;font-weight:bold;"><%= student.status %></p>
                    <% end %>
                  </td>
                  <td><%= link_to 'Show', student%></td>
                  <td><%= button_to 'Delete', student, :method => :delete, :confirm => 'Are you sure?'%></td>
                </tr>
            <% end %>

          </table>
        </td>
      </tr>
    </table>

    <table>
      <div class="fbgreybox">
        <h2>Companies<!-- <%= link_to 'New Company', new_company_path, :align => :right%>--></h2></div>
      <tr>
        <td>
          <table rules="rows" frame="void">
            <tr>
              <th style="width:280px; text-align:left;">Company name</th>
              <th style="width:180px;text-align:left;">Telephone</th>
              <th style="width:120px;text-align:left;">Intern students</th>
              <th></th>
            </tr>
            <% for company in Company.all do %>
                <tr>
                  <td><%= company.name %> </td>
                  <td><%= company.tel %></td>
                  <td>0</td>
                  <td><%= link_to 'Show', company %></td>
                  <td><%= button_to 'Delete', company, :method => :delete, :confirm => 'Are you sure?'%>
                  </td>
                </tr>
            <% end %>

          </table>
        </td>
      </tr>
    </table>
<% end %>
<%# ----------------------------------------------COMPANY------------------------------------------- %>
<% if User.find_by_id(session[:user_id]).role == "company"%>
    <table>
      <div class="fbgreybox"><h2>Company</h2></div>
      <tr>
        <td>
          <% if Company.find_by_company_id(User.find_by_id(session[:user_id]).name) %>
              <%= link_to "Edit Profile", edit_company_path(Company.find_by_company_id(User.find_by_id(session[:user_id]).name)) %>
          <% else %>
              <%= button_to "Create New Profile", new_company_path %>
          <% end %>
        </td>
      </tr>
      <tr>
        <td>
          <%= link_to "Company - Student Evaluation #1", student_evaluation_firsts_path%>
        </td>
      </tr>

      <tr>
        <td>
          <%= link_to "Company - Student Evaluation #2", student_evaluation_seconds_path%>
        </td>
      </tr>

    </table>
<% end %>
<%# ----------------------------------------------STUDENT------------------------------------------- %>
<% if User.find_by_id(session[:user_id]).role == 'student'%>
    <table>
      <div class="fbgreybox"><h2>Student</h2></div>
      <tr>
        <td>
          <% if Student.find_by_student_id(User.find_by_id(session[:user_id]).name) %>
              <%= link_to "Edit Profile", edit_student_path(Student.find_by_student_id(User.find_by_id(session[:user_id]).name)) %>
          <% else %>
              <%= button_to "Create New Profile", new_student_path %>
          <% end %>
        </td>
      </tr>
    </table>

    <div class="fbgreybox"><h2>Self & Company Evaluations</h2></div>
    <% if CompEvaluation.find_by_student_id(User.find_by_id(session[:user_id]).name)%>
        <table>
          <tr>
            <th style="width:200px; text-align:left;">Company name</th>
            <th style="width:400px;text-align:left;">Evaluation Date</th>
            <th></th>

          </tr>

          <% for comp_evaluation in CompEvaluation.all do %>
              <tr>

                <td><%= comp_evaluation.employer_name %>a</td>
                <td><%= comp_evaluation.updated_at.localtime %></td>
                <td><%= link_to 'Show', comp_evaluation %></td>

              </tr>
          <% end %>
        </table>
    <% else %>
        <%= button_to 'Start Self & Company Evaluation', new_comp_evaluation_path %>
    <% end %>

<% end %>
<%# ----------------------------------------------ADMIN------------------------------------------- %>
<% if User.find_by_id(session[:user_id]).role == "admin" %>

    <div class="fbgreybox">
      <%= button_to 'New User', new_user_path %>
    </div><p></p>

    <table>
      <div class="fbgreybox"><h2>CAMT Accounts</h2></div>
      <tr>
        <th style="width:200px;text-align:left;">User name</th>
        <th style="width:250px;text-align:left;">Created</th>
      </tr>

      <% for user in User.all do %>
          <% if user.role == "camt" %>
              <tr>
                <td><%= user.name %></td>
                <td><%= user.created_at.localtime %></td>
                <td><%= link_to 'Show', user %></td>
                <td><%= link_to 'Edit', edit_user_path(user) %></td>
                <td><%= button_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
              </tr>
          <% end %>
      <% end %>
    </table>

    <table>
      <div class="fbgreybox"><h2>Company Accounts</h2></div>
      <tr>
        <th style="width:200px;text-align:left;">User name</th>
        <th style="width:250px;text-align:left;">Created</th>
      </tr>

      <% for user in User.all do %>
          <% if user.role == "company" %>
              <tr>
                <td><%= user.name %></td>
                <td><%= user.created_at.localtime %></td>
                <td><%= link_to 'Show', user %></td>
                <td><%= link_to 'Edit', edit_user_path(user) %></td>
                <td><%= button_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
              </tr>
          <% end %>
      <% end %>
    </table>

    <table>
      <div class="fbgreybox"><h2>Student Accounts</h2></div>
      <tr>
        <th style="width:200px;text-align:left;">User name</th>
        <th style="width:250px;text-align:left;">Created</th>
      </tr>

      <% for user in User.all do %>
          <% if user.role == "student" %>
              <tr>
                <td><%= user.name %></td>
                <td><%= user.created_at.localtime %></td>
                <td><%= link_to 'Show', user %></td>
                <td><%= link_to 'Edit', edit_user_path(user) %></td>
                <td><%= button_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
              </tr>
          <% end %>
      <% end %>
    </table>

    <table>
      <div class="fbgreybox"><h2>Admin Accounts</h2></div>
      <tr>
        <th style="width:200px;text-align:left;">User name</th>
        <th style="width:250px;text-align:left;">Crated</th>
      </tr>

      <% for user in User.all do %>
          <% if user.role == "admin" %>
              <tr>
                <td><%= user.name %></td>
                <td><%= user.created_at.localtime %></td>
                <td><%= link_to 'Show', user %></td>
                <td><%= link_to 'Edit', edit_user_path(user) %></td>
                <td><%= button_to 'Delete', user, :confirm => 'Are you sure?', :method => :delete %></td>
              </tr>
          <% end %>
      <% end %>
    </table>

<% end %>

</div>
